<?php
class Semester extends AppModel {
	var $name = 'Semester';
	var $primaryKey = 'semester_id';
	var $belongsTo= array('Term' =>
					array('className' => 'Term',
								'foreignKey' => 'term_id')
			);

	function getSemesterList() {
		$semesters = $this->query("SELECT s.semester_id, s.year, t.description FROM semesters s, terms t where t.term_id=s.term_id");
		$semesterList = array();
		foreach($semesters as $semester) {
			$semesterId = $semester['s']['semester_id'];
			$year = $semester['s']['year'];
			$term = $semester['t']['description'];
			$semesterList[$semesterId] = "$year - $term";
		}
		return $semesterList;
	}
}
?>
